package com.isoft.c2team3service2.controller;


import com.isoft.c2team3service2.bean.ResponseData;
import com.isoft.c2team3service2.entity.UserDetailDTO;
import com.isoft.c2team3service2.service.UserDetailService;
import com.isoft.c2team3service2.service.impl.BusinessException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user/detail")
public class UserDetailController extends BaseController {

    @Autowired
    private UserDetailService userDetailService;

    /**
     * 根据用户ID查询详情（含帖子、点赞、关注状态）
     * @param targetUserId 被查询用户ID
     * @return 响应结果
     */
    @GetMapping("/{targetUserId}")
    public ResponseData<UserDetailDTO> getUserDetail(@PathVariable Integer targetUserId) {
        try {
            UserDetailDTO userDetail = userDetailService.getUserDetailById(targetUserId);
            return resultT(userDetail, "查询用户详情成功");
        } catch (BusinessException e) {
            return resultT(null, e.getMessage());
        } catch (Exception e) {
            return resultT(null, "查询失败：" + e.getMessage());
        }
    }
}